﻿using Bilibili.Common.Api;
using Bilibili.Model.Resource;
using PCLUntils.Json;
using System;
using System.Threading.Tasks;

namespace Bilibili.WebClient.Api
{
    public sealed class SeasonClient : ClientBase
    {
        public async Task<ReturnJObject> GetCondition(int seasonType)
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("https://api.bilibili.com/pgc/season/index/condition", $"season_type={seasonType}&type=0", false, ApiProviderBase.Build4);
                string results = await ApiClient.GetResults(apiInfo);
                return results.ParseObject<ReturnJObject>();
            }
            catch (Exception ex)
            {
                return BuildJExceptionResult(ex);
            }
        }
        public async Task<ReturnJObject> GetResult(string condition, int page, int seasonType)
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("https://api.bilibili.com/pgc/season/index/result", $"{condition}&page={page}&pagesize=20&season_type={seasonType}&type=0", false, ApiProviderBase.Build4);
                string results = await ApiClient.GetResults(apiInfo);
                return results.ParseObject<ReturnJObject>();
            }
            catch (Exception ex)
            {
                return BuildJExceptionResult(ex);
            }
        }
    }
}